
(function(ns){

var Growth = ns.Growth = Hilo.Class.create({
    Extends: Hilo.Container,
    constructor: function(properties){
		//console.log(properties)
        Growth.superclass.constructor.call(this, properties);
        this.init(properties);
    },

    init: function(properties){
		let that = this
		//console.log(properties.asset)
        var kuan = new Hilo.Bitmap({
            id: 'kuan',
			width:203,
			height:40,
            image: properties.image[0],
			x:that.width *.5,
			y:20,
			pivotX: 100,
			pivotY: 20,
			depth:8,
            rect: [0, 0, 203, 30]
        });

        var tiao = new Hilo.Bitmap({
            id: 'tiao',
            image: properties.image[1],
			x:that.width *.5078,
			y:18,
			pivotX: 100,
			pivotY: 13,
			width:0.1,
			height:32,
			depth:10,
			background:"#FFEAA9",
            rect: [0, 0, 200, 20]
        });
		
		var font = "34px arial";
		var content = "成长值：0 / 200";
		
		var growthValue = new Hilo.Text({
			id:"growth",
		    font: font,
		    text: content,
			width: that.width,
			maxWidth:1000,
		    lineSpacing: 1,
			color:"#B56507",
			textAlign: "center",
			x:0,
			y:50,
		});
		var tiaoback = new Hilo.Bitmap({
			id:"tiaoback",
			width:196,
			height:36,
			image: properties.image[2],
			x:that.width *.5 +2,
			y:19,
			pivotX: 99,
			pivotY: 19,
			depth:8,
			rect: [0, 0, 194, 20]
		});
		//console.log(growthValue.width + "-" + growthValue.height)
        this.addChild(tiaoback,tiao,kuan , growthValue);
		
    },
	getReady: function(){
		let lengValue = window.game.groupValue
		this.getChildById('tiao').width = window.game.groupValue
		if(!utilsClass.isEmpty(window.game.groupValue))
		this.getChildById('growth').text = "成长值："+window.game.groupValue+" / 200";
		else
		this.getChildById('growth').text = "成长值：0/ 200";
		
		Hilo.Tween.to(this.getChildById('tiao'), {width:window.game.groupValue==200?'191':lengValue-4}, {
		   duration: 100,
		   reverse:false,
		   loop:false
		});
	},
	doClick: function(value){
		let lengValue = value
		//console.log(value);
		if(value <201){
			this.getChildById('growth').text = "成长值："+Number(value+1)+" / 200";
			
			Hilo.Tween.to(this.getChildById('tiao'), {width:value==200?'191':lengValue-4}, {
			   duration: 100,
			   reverse:false,
			   loop:false
			});
		}
	}
});

})(window.game);